<HTML> 
<HEAD> 
	<TITLE>3rd Party ROBOTC Drivers</TITLE> 
<link href="tabs.css" rel="stylesheet" type="text/css"/> 
<link href="doxygen.css" rel="stylesheet" type="text/css"/> 
</HEAD> 
 
<BODY bgcolor="#ffffff" link="#000000" vlink="#000000"> 
<table width="100%" bgcolor="navy" cellspacing=0 cellpadding=1 border=0> 
<tr><td><table width="100%" bgcolor="#EEEEDD" cellspacing=0 cellpadding=3 border=0> 
<tr> 
    <td width="33%" align="left"> <img src="images/LOGO_NXT.gif" width=266 height=44 border="0" alt="Mindstorms"></td> 
    <td><b><font size="+3" color="navy">3rd Party ROBOTC Drivers</font></b></td> 
    <td align="right"> <img src="images/logo.png" width=44 height=44 border="0" alt="RobotC"></td>     
</tr> 
  <tr bgcolor="#cccc99" align="right"> 
          <td colspan=3> <font face="arial" size="-1"> [<a href=main.html>Home</a>] [<a target=_top href="https://sourceforge.net/projects/rdpartyrobotcdr/">Download</a>] [<a target=_top href="http://apps.sourceforge.net/mantisbt/rdpartyrobotcdr/my_view_page.php">Submit a bug/suggestion</a>]  [<a target=_top href="http://www.robotc.net/forums/">ROBOTC Forums</a>] [<a target=_top href="http://botbench.com">Blog</a>] [<a target=_top href="http://sourceforge.net/donate/index.php?group_id=257238">Support this project</a>]</font> </td> 
</tr> 
</table></td></tr> 
</table> 
<!-- Generated by Doxygen 1.7.2 -->
<div class="header">
  <div class="headertitle">
<h1>mindsensors-touchpanel-test1.c</h1>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="preprocessor">#pragma config(Sensor, S3,     MSTP,                sensorI2CCustom)</span>
<span class="preprocessor"></span><span class="comment">//*!!Code automatically generated by &#39;ROBOTC&#39; configuration wizard               !!*//</span>

<span class="comment">/*</span>
<span class="comment"> * $Id: mindsensors-touchpanel-test1.c 133 2013-03-10 15:15:38Z xander $</span>
<span class="comment"> */</span>
<span class="comment"></span>
<span class="comment">/**</span>
<span class="comment"> * mindsensors-touchpanel.h provides an API for the Mindsensors TouchPanel. This program</span>
<span class="comment"> * demonstrates how to use that API.</span>
<span class="comment"> *</span>
<span class="comment"> * Changelog:</span>
<span class="comment"> * - 0.1: Initial release</span>
<span class="comment"> *</span>
<span class="comment"> * Credits:</span>
<span class="comment"> * - Big thanks to Mindsensors for providing me with the hardware necessary to write and test this.</span>
<span class="comment"> *</span>
<span class="comment"> * License: You may use this code as you wish, provided you give credit where it&#39;s due.</span>
<span class="comment"> *</span>
<span class="comment"> * THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER. </span>
<span class="comment"></span>
<span class="comment"> * Xander Soldaat (xander_at_botbench.com)</span>
<span class="comment"> * 30 November 2011</span>
<span class="comment"> * version 0.1</span>
<span class="comment"> */</span>


<span class="preprocessor">#include &quot;<a class="code" href="mindsensors-touchpanel_8h.html" title="Mindsensors TouchPanel.">drivers/mindsensors-touchpanel.h</a>&quot;</span>


task main () {
  nxtDisplayCenteredTextLine(0, <span class="stringliteral">&quot;MindSensors&quot;</span>);
  nxtDisplayCenteredBigTextLine(1, <span class="stringliteral">&quot;TouchPnl&quot;</span>);
  nxtDisplayCenteredTextLine(3, <span class="stringliteral">&quot;Noise-a-Tron&quot;</span>);
  nxtDisplayCenteredTextLine(5, <span class="stringliteral">&quot;Connect sensor&quot;</span>);
  nxtDisplayCenteredTextLine(6, <span class="stringliteral">&quot;to S3&quot;</span>);
  wait1Msec(2000);
  eraseDisplay();

  <span class="keywordtype">int</span> x, y = 0;
  ubyte buttons = 0;
  <span class="keywordtype">int</span> multiplierX = 10;
  <span class="keywordtype">int</span> multiplierY = 10;
  <span class="keywordflow">while</span> (<span class="keyword">true</span>) {
    <span class="keywordflow">if</span> (!<a name="a0"></a><a class="code" href="group__mptp.html#gaedbbf52bc792bbb063d8c95abb7d49ae">MSTPgetTouch</a>(MSTP, x, y, buttons))
      PlaySound(soundBlip);
    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a name="a1"></a><a class="code" href="group__mptp.html#ga6188bab9bc7fd9d5574ede7529cce053">isButtonTouched</a>(buttons, <a name="a2"></a><a class="code" href="group__mptp.html#ga76cbe60b17d0d40b6f4441b898504f69">BUTTON_L1</a>))
      multiplierX = 10;
    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="group__mptp.html#ga6188bab9bc7fd9d5574ede7529cce053">isButtonTouched</a>(buttons, <a name="a3"></a><a class="code" href="group__mptp.html#ga30bb0bb1edb52038138602344a892fc8">BUTTON_L2</a>))
      multiplierX = 15;
    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="group__mptp.html#ga6188bab9bc7fd9d5574ede7529cce053">isButtonTouched</a>(buttons, <a name="a4"></a><a class="code" href="group__mptp.html#gac50479823adca0fbf39a3cace2b6cb78">BUTTON_L3</a>))
      multiplierX = 20;
    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="group__mptp.html#ga6188bab9bc7fd9d5574ede7529cce053">isButtonTouched</a>(buttons, <a name="a5"></a><a class="code" href="group__mptp.html#ga53e495a1f49afbae4f3b53ac3e8c8231">BUTTON_L4</a>))
      multiplierX = 25;
    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="group__mptp.html#ga6188bab9bc7fd9d5574ede7529cce053">isButtonTouched</a>(buttons, <a name="a6"></a><a class="code" href="group__mptp.html#ga0d1e25e9a7b1ae94e302e91314270941">BUTTON_R1</a>))
      multiplierY = 10;
    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="group__mptp.html#ga6188bab9bc7fd9d5574ede7529cce053">isButtonTouched</a>(buttons, <a name="a7"></a><a class="code" href="group__mptp.html#ga7de1af17484bf0192c373643c2ef10ec">BUTTON_R2</a>))
      multiplierY = 15;
    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="group__mptp.html#ga6188bab9bc7fd9d5574ede7529cce053">isButtonTouched</a>(buttons, <a name="a8"></a><a class="code" href="group__mptp.html#ga9367cf9e8510b1824384ba3a844bd70b">BUTTON_R3</a>))
      multiplierY = 20;
    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="group__mptp.html#ga6188bab9bc7fd9d5574ede7529cce053">isButtonTouched</a>(buttons, <a name="a9"></a><a class="code" href="group__mptp.html#ga5ff6a4a783590392793d28079ed5c3b1">BUTTON_R4</a>))
      multiplierY = 25;

    <span class="keywordflow">else</span> <span class="keywordflow">if</span> (x &gt; 0 &amp;&amp; y &gt; 0)
    {
      PlayImmediateTone(x * multiplierX, 1);
      wait1Msec(10);
      PlayImmediateTone(y * multiplierY, 1);
      nxtSetPixel(x, y);
    }
    EndTimeSlice();
  }
}
</pre></div> </div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Wed Mar 13 2013 19:56:42 for ROBOTC Drivers by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
</body>
</html>
